<template>
    <div>
        <header-footer :commonData="{$parent:$parent,indexLogo:1}">
            <div class="newsInfo" v-cloak>
                <div class="crumb width1200">
                    <ul>
                        <li class="f_left">当前位置：</li>
                        <li class="f_left">
                            <router-link to="/index">首页></router-link>
                        </li>
                        <li class="f_left">新闻中心</li>
                    </ul>
                </div>
                
                <div class="news_content news_info_content text_center">
                    <h3 class="news_info_title">{{newsInfo.title}}</h3>
                    <p class="news_info_title_fu color666"><span class="news_info_resource">来源：{{newsInfo.sources}}</span>
                        {{new Date(newsInfo.updateTime).Format("yyyy-MM-dd hh:mm:ss")}}</p>
                    <div class="news_info_text ql-editor" v-html="newsInfo.contextText" style="min-height: 400px;">
                        <!-- {{newsInfo.contextText}} -->
                    </div>
                </div>
            </div>
        </header-footer>
    </div>
</template>

<script>
    import headerFooter from '../../components/header_and_footer.vue'
    export default {
        name: 'news_info',
        data() {
            return {
                id: parseInt(this.$route.params.id),
                newsInfo: {
                    contextText:''
                }
            }
        },
        created: function() {
            var that = this;
            this.common.post(this.api.getNews, {
                id: this.id,
            }, function(res) {
                res.resultMap.contextText="";
                that.newsInfo = res.resultMap;
                that.getContentText(res.resultMap.contextUrl)
            });
        },
        mounted: function() {},
        methods: {
            getContentText: function(url) {
                var that = this;
                const options = {
                    method: 'GET',
                    mode: "no-cors",
                    credentials: 'include',
                    headers: {
                        "Content-Type": "text/plain"
                    },
                };
                window.fetch(url)
                    .then(response => response.text())
                    .then(response => {
                        console.log(response)
                        that.newsInfo.contextText = response;
                    })
            },
        },
        components: {
            headerFooter
        }
    }
</script>


<style>
</style>
